package com.dusk.net
{
	import com.game.data.vo.LevelConfigVO;
	import com.game.module.backpack.view.PackThings;
	
	import config.Config;
	
	public class AssetBundle
	{
		public static function getInGameAssets():Array
		{
			var arr:Array = Config.getIns().configManager.resProxy.getConfigBId("BaseAsset") as Array;
			var ret:Array = [];
			for each (var item:Object in arr)
			{
				ret.push(AssetUrl.getCommonAssetsUrl(item.name));
			}
			return ret;
		}
		
		public static function getInGameLibs():Array
		{
			var arr:Array = Config.getIns().configManager.resProxy.getConfigBId("GameLib") as Array;
			var ret:Array = [];
			for each (var item:Object in arr)
			{
				ret.push(AssetUrl.getCommonAssetsUrl(item.name));
			}
			return ret;
		}
		
		public static function getInBattleAssets(data:LevelConfigVO):Array
		{
			var ret:Array = [];
			var files:Array = Config.getIns().configManager.resProxy.getConfigBId("MustLoad") as Array
			for each (var item:Object in files)
			{
				ret.push(AssetUrl.getCommonAssetsUrl(item.name))
			}
			var names:Array = [];
			names.push(data.getLevelIDArray()[0].toString());
			names = names.concat(getRolesAndPetsAssets());//人物和宠物素材
			names = names.concat(data.extraAssets);//本关额外素材
			for each (var i:String in names)
			{
				ret.push(AssetUrl.getCommonAssetsUrlByName(i));
			}
			return ret;
		}
		
		private static function getRolesAndPetsAssets():Array
		{
			var arr:Array = [];
			var i:*;
			var name:String;
			if (Config.getIns().playerData.roleId > 0)
			{
				for each(i in Config.getIns().playerData.petList)
				{
					name = i.getPetName().replace(/[0-9]/g, "");
					arr.push("pet/" + name);
				}
			}
			if (Config.getIns().playerData.roleId > 0)
			{
				arr = arr.concat(getRoleAssetByRoleId(Config.getIns().playerData.roleId));
			}
			return arr;
		}
		
		private static function getRoleAssetByRoleId(param1:uint):Array
		{
			return [AssetUrl.getRoleAssetUrl("Role" + param1.toString()),AssetUrl.getRoleAssetUrl("Role" + param1.toString() + "Equipment")];
		}
	}
}
